home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / nice / RCS / nice.c,v < prev    next >
Encoding:
Text File  |  1991-03-18  |  1.7 KB  |  111 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    stolcke:1.2; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.2
  10. date     91.03.17.23.08.41;  author stolcke;  state Exp;
  11. branches ;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     91.03.17.22.13.48;  author stolcke;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @@
  22.  
  23.  
  24. 1.2
  25. log
  26. @*** empty log message ***
  27. @
  28. text
  29. @/*
  30.  * Copyright (c) 1980 Regents of the University of California.
  31.  * All rights reserved.  The Berkeley software License Agreement
  32.  * specifies the terms and conditions for redistribution.
  33.  */
  34.  
  35. #ifndef lint
  36. char copyright[] =
  37. "@@(#) Copyright (c) 1980 Regents of the University of California.\n\
  38.  All rights reserved.\n";
  39. #endif not lint
  40.  
  41. #ifndef lint
  42. static char sccsid[] = "@@(#)nice.c    5.2 (Berkeley) 1/12/86";
  43. #endif not lint
  44.  
  45. #include <stdio.h>
  46.  
  47. #include <sys/time.h>
  48. #include <sys/resource.h>
  49.  
  50. #ifdef sprite
  51. #include "proc.h"
  52. #include "status.h"
  53. #endif
  54.  
  55. main(argc, argv)
  56.     int argc;
  57.     char *argv[];
  58. {
  59.     int nicarg = 10;
  60.  
  61.     if (argc > 1 && argv[1][0] == '-') {
  62.         nicarg = atoi(&argv[1][1]);
  63.         argc--, argv++;
  64.     }
  65.     if (argc < 2) {
  66.         fputs("usage: nice [ -n ] command\n", stderr);
  67.         exit(1);
  68.     }
  69. #ifndef sprite
  70.     if (setpriority(PRIO_PROCESS, 0, 
  71.         getpriority(PRIO_PROCESS, 0) + nicarg) < 0) {
  72.         perror("setpriority");
  73.         exit(1);
  74.     }
  75. #else
  76.     {
  77.         int status, prio, pid;
  78.  
  79.         pid = getpid();
  80.         status = Proc_GetPriority(pid, &prio);
  81.         if (status != 0) {
  82.             fprintf(stderr, "nice: 0x%x: %s\n", pid,
  83.                 Stat_GetMsg(status));
  84.             return (1);
  85.         }
  86.         status = Proc_SetPriority(pid, -((-prio*10)+nicarg)/10, 0);
  87.         if (status != 0) {
  88.             fprintf(stderr, "nice: 0x%x: %s\n", pid,
  89.                 Stat_GetMsg(status));
  90.             return (1);
  91.         }
  92.     }
  93. #endif
  94.  
  95.     execvp(argv[1], &argv[1]);
  96.     perror(argv[1]);
  97.     exit(1);
  98. }
  99. @
  100.  
  101.  
  102. 1.1
  103. log
  104. @Initial revision
  105. @
  106. text
  107. @d22 5
  108. d41 1
  109. d47 20
  110. @
  111.